/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "driver")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Driver.findAll", query = "SELECT d FROM Driver d"),
    @NamedQuery(name = "Driver.findByIddriver", query = "SELECT d FROM Driver d WHERE d.iddriver = :iddriver")})
public class Driver implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "iddriver")
    private Integer iddriver;
    @JoinColumn(name = "iddepot", referencedColumnName = "iddepot")
    @ManyToOne
    private Depot iddepot;
    @JoinColumn(name = "iduser", referencedColumnName = "iduser")
    @ManyToOne
    private User iduser;
    @JoinColumn(name = "idvehicle", referencedColumnName = "idvehicle")
    @ManyToOne
    private Vehicle idvehicle;
    @OneToMany(mappedBy = "iddriver")
    private List<Attendance> attendanceList;

    public Driver() {
    }

    public Driver(Integer iddriver) {
        this.iddriver = iddriver;
    }

    public Integer getIddriver() {
        return iddriver;
    }

    public void setIddriver(Integer iddriver) {
        this.iddriver = iddriver;
    }

    public Depot getIddepot() {
        return iddepot;
    }

    public void setIddepot(Depot iddepot) {
        this.iddepot = iddepot;
    }

    public User getIduser() {
        return iduser;
    }

    public void setIduser(User iduser) {
        this.iduser = iduser;
    }

    public Vehicle getIdvehicle() {
        return idvehicle;
    }

    public void setIdvehicle(Vehicle idvehicle) {
        this.idvehicle = idvehicle;
    }

    @XmlTransient
    public List<Attendance> getAttendanceList() {
        return attendanceList;
    }

    public void setAttendanceList(List<Attendance> attendanceList) {
        this.attendanceList = attendanceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddriver != null ? iddriver.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Driver)) {
            return false;
        }
        Driver other = (Driver) object;
        if ((this.iddriver == null && other.iddriver != null) || (this.iddriver != null && !this.iddriver.equals(other.iddriver))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Driver[ iddriver=" + iddriver + " ]";
    }
    
}
